<?php
$layout = of_get_option('side_bar');
$layout = (empty($layout)) ? 'right_side' : $layout;

get_header(); ?>
		<!--[if lt IE 8]>
		<div id="ie-warning" class="alert alert-danger fade in visible-lg">
			<button type="button" class="close" data-dismiss="alert">&times;</button>
			<i class="fa fa-warning"></i> 请注意，本博客不支持低于IE8的浏览器，为了获得最佳效果，请下载最新的浏览器，推荐下载 <a href="http://www.google.cn/intl/zh-CN/chrome/" target="_blank"><i class="fa fa-compass"></i> Chrome</a>
            </div>
		<![endif]-->
		<?php if($layout == 'left_side'){ ?>
		<aside class="col-md-4 hidden-xs hidden-sm">
			<div id="sidebar">
				<?php dynamic_sidebar( 'sidebar_home'); ?>
			</div>
		</aside>
		<?php } ?>
        <section id='main' class='<?php echo ($layout == 'single') ? 'col-md-12' : 'col-md-8'; ?>' >
			<!--首页幻灯片-->
			<?php
				if(is_home()){
					//specs_slide();
					$a1= array('a' => "11","b"=>"22" );
					$a2 = array('c' => "33","d"=>"44",$a1 );
					//echo json_encode($a2);
					//echo '<p />';
					$first_items = json_decode(of_get_option("first_items" ),true);
					//var_dump($first_items);
					vpn358_parse_items($first_items);
					//echo of_get_option("first_items" );
					//var_dump($args);
					//echo '<p />';
					$second_items = json_decode(of_get_option("second_items" ),true);
					//echo of_get_option("second_items" );
					//var_dump($second_items);
					vpn358_parse_items($second_items);

					$third_items = json_decode(of_get_option("third_items" ),true);
					//echo of_get_option("third_items" );
					//var_dump($third_items);
					vpn358_parse_items($third_items);
					$four_items = json_decode(of_get_option("four_items" ),true);
					//echo of_get_option("four_items" );
					//var_dump($four_items);
					vpn358_parse_items($four_items);
					$five_items = json_decode(of_get_option("five_items" ),true);
					//echo of_get_option("five_items" );
					//var_dump($five_items);
					vpn358_parse_items($five_items);
					$six_items = json_decode(of_get_option("six_items" ),true);
					//echo of_get_option("six_items" );
					//var_dump($six_items); 
					vpn358_parse_items($six_items);
					/*
					echo '<div class="row"><div class="col-xs-12 col-md-12">';
					$args = json_decode(of_get_option("artical_image_slider" ),true);
					//var_dump( $args);
					//article_image_slide($args);
					echo desc_image_slide($args);
					echo '</div></div>';
					echo '<div class="row"><div class="col-xs-12 col-md-6">';
					
					//var_dump( $args);
					//$args=array("menu1"=>"menu_1","menu2"=>"menu_2","menu3"=>"menu_3");
					$args = json_decode(of_get_option("vpn358_menu_json" ),true);
					//var_dump($args);
					echo vpn358_menu($args);
					echo '</div><div class="col-xs-12 col-md-6">';
					echo desc_image_slide($args);
					echo '</div>';

					echo '<div class="col-xs-12 col-md-6">';
					$args = json_decode(of_get_option("artical_image_slider" ),true);
					article_image_slide($args);
					echo '</div>';
					echo '</div>';
					*/
					

				}elseif(is_category()){
			?>
					<header class="archive-header well">
						<h1 class="archive-title">
							分类目录：<?php echo single_cat_title( '', false );?>
						</h1>
						<div class="archive-meta">
						<?php if ( category_description() ) : // Show an optional category description ?>
							<?php echo category_description(); ?>
						<?php else: ?>
							以下是分类 <?php echo single_cat_title( '', false );?> 下的所有文章
						<?php endif;?>
						</div>
					</header>
			<?php
				}elseif(is_author()){
			?>
					<header class="author-header well clearfix">
						<div class="pull-left author-avatar">
							<?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'twentytwelve_author_bio_avatar_size', 50 ) ); ?>
						</div>
						<div class="author-meta">
							<h1 class="author-title">
								作者：<?php echo get_the_author();?>
							</h1>
							<?php if ( get_the_author_meta( 'description' ) ) : ?>
								<div class="archive-meta"><?php the_author_meta( 'description' ); ?></div>
							<?php endif; ?>
						</div>
					</header>
			<?php
				}elseif(is_tag()){
			?>
					<header class="archive-header well">
						<h1 class="archive-title">
							标签目录：<?php echo single_cat_title( '', false );?>
						</h1>
						<?php if ( category_description() ) : // Show an optional category description ?>
							<div class="archive-meta"><?php echo category_description(); ?></div>
						<?php else: ?>
							以下是与标签 “<?php echo single_cat_title( '', false );?>” 相关联的文章
						<?php endif;?>
					</header>
			<?php
				}elseif(is_search()){
			?>
					<header class="archive-header well">
						<h1 class="archive-title">
							搜索结果：<?php the_search_query(); ?>
						</h1>
						<div class="navbar navbar-default">
							<form class="navbar-form" role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
								<div class="input-group">
									<input type="text" class="form-control" value="<?php the_search_query(); ?>" name="s" id="s" >
									<span class="input-group-btn">
									<button type="submit" class="btn btn-danger" id="searchsubmit"> 搜 索 </button>
									</span>
								</div>
							</form>
						</div>
					</header>
			<?php
				}
			if (false){
			//if(is_home()){
			?>
			
			<div class="row">
				<div class="col-xs-12 col-md-12">
				<?php 
				
				$args = json_decode(of_get_option("cat_list_2top" ),true);
				echo cat_list_2top($args) ;
				?>
				</div>
			</div>
			<div class="row">
				<div class="col-xs-12 col-md-6">
				<?php 
				$args = json_decode(of_get_option("archives1_left" ),true);
				//$args = json_decode(of_get_option("cat_list_2top" ),true);
				//var_dump($args);
				$args['show_content']=false;
				echo cat_list_top($args) ;
				?>
				</div>
				<div class="col-xs-12 col-md-6">
				<?php 

				
				$args = json_decode(of_get_option("archives1_right" ),true);
				echo cat_list_top($args) ;
				?>
				</div>
			</div>
			<div class="row">
				<div class="col-xs-12 col-md-12">
				<?php 
				$len_title = 28;

				$args = array('cat_id' => 12, 'count' => 4, 
						'len_title'=> $len_title, 'icon'=> 'fa fa-book',
						'long_len_title'=>80,
						'style'=>"panel-warning",
						'length_content' => 140);
				$args = json_decode(of_get_option("archives3" ),true);
				echo cat_list_top($args) ;
				?>
				</div>
			</div>
			<div class="row">
				<?php 
				$args = json_decode(of_get_option("top_images_slider" ),true);
					echo '<div class="col-xs-12 col-md-12">';
					article_slide($args);
					///var_dump( $args);
					echo '</div>';

				$args=array("menu1"=>"primary","menu2"=>"primary");
				//echo menu($args);
				
				
					?>
				
			</div>
			<div class="row">
				<div class="col-xs-12 col-md-6">
				<?php 
				$len_title = 18;
				$long_len_title=20;
				$args = array('cat_id' => 4,  'count' => 5, 
						'len_title'=> $len_title, 'length_content' => 0,
						'long_len_title'=>$long_len_title,
						'icon'=> 'fa fa-bookmark');
				$args = json_decode(of_get_option("archives2_left" ),true);
				echo cat_list_title($args);
				?>
				</div>
				<div class="col-xs-12 col-md-6">
				<?php 
				$args = array('cat_id' => 12, 'count' => 5, 
					'len_title'=> $len_title, 'icon'=> 'fa fa-book',
					'long_len_title'=>$long_len_title,
					'length_content' => 0);
				$args = json_decode(of_get_option("archives2_right" ),true);
				echo cat_list_title($args);
				?>
				</div>
			</div>
			<?php
			$args = json_decode(of_get_option("top_images_art" ),true);
			echo '<div class="row"><div class="col-xs-12 col-md-12">'.thumbnail_wall($args)."</div></div>";
			}
			?>
			<!--首页文章列表模块-->
            <?php
            if (!is_home()) {
				if ( have_posts() ) {
					
					while ( have_posts() ){
						the_post();
						get_template_part( 'inc/post-format/content', get_post_format() );
						$ads_show_pos = of_get_option('ads_show_pos', false);
						$ads = of_get_option('ads_index_list', false);
						$ads_pos = of_get_option('ads_index_list_pos',1);
						if($ads_show_pos['index'] && $ads){
							if ($wp_query->current_post == $ads_pos ){
								echo '<div class="ads_index_list">' . $ads . '</div>';
							}
						}
					}
				}else{
			?>
			<article class="alert alert-warning"><?php _e('非常抱歉，没有相关文章。'); ?></article>
			<?php } 
			
			?>
			<!--首页文章列表模块-->
			<!--分页-->
			<?php specs_pages();
			}
			?>
        </section>
        <!--侧边栏-->
		<?php if($layout == 'right_side'){ ?>
		<aside class="col-md-4 hidden-xs hidden-sm">
			<div id="sidebar">
				<?php dynamic_sidebar( 'sidebar_home'); ?>
			</div>
		</aside>
		<?php } ?>
<?php get_footer(); ?>
